<?php

function nobel_user_views_data() {

  $data['visit_log']['table']['group'] = t('Custom Tables');
  $data['visit_log']['table']['base'] = array(
    'field' => 'id',
    'title' => t('visit log'),
    'help' => t(''),
    'weight' => -10,
  );

  $data['visit_log']['table']['join'] = array(
    'node' => array(
      'left_field' => 'nid',
      'field' => 'nid',
    ),
    'users' => array(
      'left_field' => 'uid',
      'field' => 'uid',
    ),
  );

  $data['visit_log']['id'] = array(
    'title' => t('Id'),
    'help' => t('Just a Id field'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  $data['visit_log']['nid'] = array(
    'title' => t('访问记录 nid'),
    'help' => t('node relationship'),
    'relationship' => array(
      'base' => 'node',
      'base field' => 'nid',
      'handler' => 'views_handler_relationship',
      'label' => t('node relationship'),
      'title' => t('node relationship'),
      'help' => t('node relationship'),
    ),
  );

  $data['visit_log']['uid'] = array(
    'title' => t('访问记录 uid'),
    'help' => t('users relationship'),
    'relationship' => array(
      'base' => 'users',
      'base field' => 'uid',
      'handler' => 'views_handler_relationship',
      'label' => t('users relationship'),
      'title' => t('users relationship'),
      'help' => t('users relationship'),
    ),
  );

  $data['visit_log']['remark'] = array(
    'title' => t('Plain text field'),
    'help' => t('Just a Remark text field.'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );

  $data['visit_log']['type'] = array(
    'title' => t('Numeric field'),
    'help' => t('Just a numeric field.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  $data['visit_log']['date'] = array(
    'title' => t('date field'),
    'help' => t('Just a timestamp field.'),
    'field' => array(
      'handler' => 'views_handler_field_date',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort_date',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_date',
    ),
  );

  $data['visit_log']['datetime'] = array(
    'title' => t('datetime field'),
    'help' => t('Just a timestamp field.'),
    'field' => array(
      'handler' => 'views_handler_field_date',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort_date',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_date',
    ),
  );

  return $data;
}